From: Florian Müllner Date: Wed, 11 Aug 2021 22:24:02 +0000 (+0200) Subject: appMenu: Clean up on destroy X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~574^2^2~111 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=07daa95393b2ad482b59d5c498b3f82964bbb64b;p=gnome-shell.git appMenu: Clean up on destroy For now the menu is only used in the top bar, where we can assume that it exists "forever". This won't be the case when we start reusing it elsewhere, so make sure we clean up after ourselves. Part-of: --- diff --git a/js/ui/appMenu.js b/js/ui/appMenu.js index ae6aa16a0..42c92a422 100644 --- a/js/ui/appMenu.js +++ b/js/ui/appMenu.js @@ -55,8 +55,12 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu { this.addAction(_('Quit'), () => this._app.request_quit()); - this._appSystem.connect('installed-changed', - () => this._updateDetailsVisibility()); + this._signals = []; + this._signals.push([ + this._appSystem, + this._appSystem.connect('installed-changed', + () => this._updateDetailsVisibility()), + ]); this._updateDetailsVisibility(); } @@ -65,6 +69,17 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu { this._detailsItem.visible = sw !== null; } + /** */ + destroy() { + super.destroy(); + + for (const [obj, id] of this._signals) + obj.disconnect(id); + this._signals = []; + + this.setApp(null); + } + /** * @returns {bool} - true if the menu is empty */